// featurePackage/components/giftBuyCardItem/index.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    recordItem: {
      type: Object,
      value: { type: 1 }
    },
    //buy购卡记录， bind:绑卡记录
    type: {
      type: String,
      value: "buy"
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    copyCardNum() {
      if (this.properties.recordItem.type != 1) {
        let text = this.properties.recordItem.cardNo;
        wx.setClipboardData({
          data: text,
          success: function (res) {
            wx.getClipboardData({
              success: function (res) {
                wx.showToast({
                  title: '复制礼品卡号成功'
                })
              },
              fail: function (err) {
                wx.showToast({
                  title: '复制失败',
                  icon: "none"
                })
              }
            })
          }
        })
      }
    },
    pushToBind(){
      app.globalData.giftCardNo = this.properties.recordItem.cardNo
      wx.navigateTo({
        url: '/featurePackage/pages/giftCardBind/giftCardBind',
      })
    },
  }
})
